local blaze = require "blaze"
local game = require "club.threecard.sudoku"
local const = game.util.const

local M = game.ui.element()

function M:on_injected(bind)
    bind("button.click", self.menu_item1, self.on_item1_click)
    bind("button.click", self.menu_item2, self.on_item2_click)
    bind("button.click", self.menu_item3, self.on_item3_click)
end

function M:on_item1_click()
    game.audio.post("click")

    if game.reconnection.resume() then
        return
    end
    game.router.push("/club.threecard.sudoku/rooms")
end

function M:on_item2_click()
    game.audio.post("click")
    if game.reconnection.resume() then
        return
    end
    game.kbe.player().room_api
    :enter_by_config(const.LADDER_ROOM_ID)
    :next(function()
        game.game_scene.enter(const.LADDER_ROOM_ID)
    end)
end

function M:on_item3_click()
    game.audio.post("click")
    if game.reconnection.resume() then
        return
    end
    game.router.push("/club.threecard.sudoku/versus-list")
end

return M